# coding = 'utf-8'

"""
 数据增强主程序使用的数据格式均为数字： 使用此程序改名
"""
import os
img_path = '../voc2020/images'
xml_path = '../voc2020/Annotations'


files = os.listdir(img_path)
for i, file in enumerate(files):
    filename=file.split('.')[0].split('_')[1]
    extname = file.split('.')[1];
    NewName = os.path.join(img_path, ""+filename+'.'+extname)
    OldName = os.path.join(img_path, file)
    print(NewName)
    print(OldName)
    os.rename(OldName, NewName)

xml_files = os.listdir(xml_path)
for i, file in enumerate(xml_files):
    filename=file.split('.')[0].split('_')[1]
    extname = file.split('.')[1];
    NewName = os.path.join(xml_path, ""+filename+'.'+extname)
    OldName = os.path.join(xml_path, file)
    print(NewName)
    print(OldName)
    os.rename(OldName, NewName)
